package com.shujia.mllib

import org.wltea.analyzer.core.{IKSegmenter, Lexeme}

import java.io.StringReader
import scala.collection.mutable.ListBuffer

object Demo08IK {
  def fit(str: String): String = {
    val reader: StringReader = new StringReader(str)
    val ik: IKSegmenter = new IKSegmenter(reader, true)
    var lexeme: Lexeme = ik.next()
    val lb: ListBuffer[String] = ListBuffer[String]()
    while (lexeme != null) {
      lb.append(lexeme.getLexemeText)
      lexeme = ik.next()
    }
    lb.mkString(" ")
  }

  def main(args: Array[String]): Unit = {
    val text: String = "数加学院牛逼"
    println(Demo08IK.fit(text))
  }

}
